﻿using Microsoft.Xna.Framework;

namespace Project1
{
    public abstract class Pickup : BoundedObject
    {
        public Pickup(Game1 g, string asset_name, Vector2 position)
            : base(g, asset_name, position)
        {
            Dead = false;
        }

        public bool Dead { get; private set; }

        public override bool OnPlayerCollide(Player p)
        {
            return (Dead = _onPlayerCollide(p));
        }

        protected abstract bool _onPlayerCollide(Player p);
    }

    public class PhonePickup : Pickup
    {
        const string AssetName = "phone";

        public PhonePickup(Game1 g, Vector2 position) :
            base(g, AssetName, position) { }

        protected override bool _onPlayerCollide(Player p)
        {
            var _game = Game as Game1;
            _game.cash += 10;
            return true;
        }
    }

    public class BombPickup : Pickup
    {
        const string AssetName = "bomb";
        Vector2 strength = new Vector2(10.0f, 800.0f);

        public BombPickup(Game1 g, Vector2 pos) : base(g, AssetName, pos) { }

        protected override bool _onPlayerCollide(Player p)
        {
            (Game as Game1).cash -= 5;
            var dir = p.Position.X < Position.X ? -1 : 1;
            p.OnGround = false;
            p.Velocity = new Vector2(strength.X * dir, strength.Y);
            return true;
        }
    }
}
